/*
 __  __  __    ____    ____    ___    ___    ___   
/\ \/\ \/\ \  /',__\  /',__\  /'___\ /'___\ /'___\ 
\ \ \_/ \_/ \/\__, `\/\__, `\/\ \__//\ \__//\ \__/ 
 \ \___x___/'\/\____/\/\____/\ \____\ \____\ \____\
  \/__//__/   \/___/  \/___/  \/____/\/____/\/____/
                                                   
  */


//2010-4-15

#include "wssccc.h"

void mazeLoop(){
	while(1){
		
		detectSensors();
		
		
		if(!impact(FORE_SENSOR)&&impact(LEFT_SENSOR))forward(5,10);
		
		if(impact(FORE_SENSOR)&&impact(RIGHT_SENSOR)){
			turnLeft(10);
			forward(5,10);
		}
						  
		if(impact(LEFT_SENSOR)&&impact(FORE_SENSOR))turnRight(10);
		
		if(!impact(FORE_SENSOR)&&!impact(LEFT_SENSOR)&&!impact(RIGHT_SENSOR)){
			backward(1,5);
		}
		

#if CRITICAL	
		if(impact(FORE_SENSOR)&&!impact(LEFT_SENSOR)){
			while(!impact(LEFT_SENSOR))backward(2);
		}
#endif
		
		
	}
}



void main(){
	int i;
	init_devices();
	
	
	//while(1)detectSensors();
	
	mazeLoop();
	
	
	
	
}
